<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>

<%@ taglib uri="http://ckeditor.com" prefix="ckeditor" %>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><s:if test="content.contentId==null"><s:text name="content.add.title"/></s:if><s:else><s:text name="content.edit.title"/></s:else></title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%>
	<script type="text/javascript" src="${ctx}/js/jquery.progressbar.js"></script>
	<script type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>

</head>
<body>
<div id="wrapper">
<div id="main_box">
	<div class="curmb"><s:text name="your.site.position"/>:<a href="${ctx}/welcome.action"><s:text name="homepage"/></a><span>></span><s:text name="content.title"/></div>
	<div class="listtit">
		<p>
			<span>
				<strong class="fl">
					<s:if test="content.contentId==null"><s:text name="content.add.title"/></s:if>
					<s:elseif test="cflag!=null&&cflag.equals(\"1\")"><s:text name="content.audit.title"/></s:elseif>
					<s:else><s:text name="content.edit.title"/></s:else> 
				</strong>
				<a href="#this" style="float:right;margin-right:15px;line-height:24px;font-weight: bold;" id="import"><s:text name="content.importXtbg"/></a>
			</span>
		</p>
	</div>
	<div class="listadd">
		<%-- <s:form action="content-upload"  enctype="multipart/form-data" method="post" onsubmit="return chkform()"> --%>
		<s:form action="content-save" id="save-form">
		<s:hidden name="cflag" id="cflag"/>
		<s:hidden name="tflag"/>
		<s:hidden name="indexflag"/>
		<s:hidden name="content.contentId"/>
		<s:hidden name="content.category.categoryId"/>
		<s:hidden name="topic.topicId"/>
		<s:hidden name="contentAttach.attachId"/>
		<s:hidden name="contentAttach.attachMemo" id="memo"/>
		<s:hidden name="content.showType"/>
		<s:hidden name="content.isTop"/>
		<s:hidden name="content.contentStatus"/>
	 
		<s:hidden name="pb"/>
		<s:hidden name="pbMax"/>
		<s:hidden name="listId"/>
		<table class="addgrid">
			<s:if test="topic.topicName!=null">
			<tr>
				<th><s:text name="content.cmsTopic"/>:</th>
				<td><s:text name="topic.topicName"/></td>
			</tr>
			</s:if><s:else>
			<tr>
				<th><s:text name="content.cmsCategory"/>:</th>
				<td><s:property value="content.category.catName"/></td>
			</tr>
			</s:else>
			<tr>
				<th><span id="contentTitle_span" style="color:red">*</span><s:text name="content.contentTitle"/>:</th>
				<td><select name="showType_1"><option value="1">原创</option><option value="0">转载</option></select><s:textfield id="contentTitle" name="content.contentTitle" required="true" requiredposition="right" cssClass="txtin450" onkeyup="checkTitle()" /><span id="contentTitleno"></span>
					<a href="#this" onclick="addSimpleTitle()">*添加文章副标题</a><span id="catContentTitleAlert" style="color :red"><s:property value="content.category.catContentTitleAlert"/></span>
				</td>
			</tr>
			<tr id="simpleT_1">
				<th>文章副标题:</th>
				<td><s:textfield id="content.simpleTitle1" name="content.simpleTitle1" cssClass="txtin450" onblur="simpleTitle1(this)"/><a href="#this" onclick="removeSimpleTitle('simpleT_1')">删除文章副标题</a></td>
			</tr>
			<tr id="simpleT_2">
				<th>文章副标题:</th>
				<td><s:textfield id="content.simpleTitle2" name="content.simpleTitle2" cssClass="txtin450" onblur="simpleTitle2(this)"/><a href="#this" onclick="removeSimpleTitle('simpleT_2')">删除文章副标题</a></td>
			</tr>
			<tr id="simpleT_3">
				<th>文章副标题:</th>
				<td><s:textfield id="content.simpleTitle3" name="content.simpleTitle3" cssClass="txtin450" onblur="simpleTitle3(this)"/><a href="#this" onclick="removeSimpleTitle('simpleT_3')">删除文章副标题</a></td>
			</tr>
			<tr>
				<th>自定义属性:</th>
				<td>
					<input type="checkbox" name="isTop_f" id="isTop_f"/><label for="isTop_f">置顶</label>
					<input type="checkbox" name="showType_o" id="showType_o_1"/><label for="showType_o_1">最新</label>
					<input type="checkbox" name="showType_o" id="showType_o_2"/><label for="showType_o_2">推荐</label>
					<input type="checkbox" name="showType_o" id="showType_o_3"/><label for="showType_o_3">精选</label>
					<input type="checkbox" name="showType_o" id="showType_o_4"/><label for="showType_o_4">热点</label>
				</td>
			</tr>
			<tr>
				<th nowrap="nowrap">是否允许评论:</th>
				<td>
					<s:if test="content.category.isComment">
						<s:select list="dicIsComment" value="content.isComment" name="content.isComment" cssClass="selectClass" listKey="dictionaryKey" listValue="dictionaryValue"/>
					</s:if>
					<s:else>
						<s:select list="dicIsComment" value="content.category.isComment" name="content.isComment" cssClass="selectClass" listKey="dictionaryKey" listValue="dictionaryValue" disabled="true" />
					</s:else>
				</td>
			</tr>
			<tr>
				<th><span id="contentTitle_span" style="color:red">*</span><s:text name="content.contentSource"/>:</th>
				<td><s:textfield id="contentSource" name="content.contentSource" required="true" requiredposition="right" cssClass="txtin450"/><span id="contentSourceno"></span></td>
			</tr>
			<tr>
				<th><s:text name="content.contentAuthor"/>:</th>
				<td><s:textfield id="content.contentAuthor" name="content.contentAuthor" required="true" requiredposition="right" cssClass="txtin" onblur="contentAuthor(this)"/></td>
			</tr>
			<tr>
				<th><s:text name="key.words"/>:</th>
				<td><s:textfield id="keywords" name="content.keywords" required="true" requiredposition="right" cssClass="txtin" /><span id="keywordsno">多个关键字请以','隔开</span></td>
			</tr>
			<tr>
				<th><span id="contdesction" style="color:red">*</span><s:text name="content.contentDescription"/>:</th>
				<td>
					<s:textarea id="contentDescription" onblur="checkDes(this)" name="content.contentDescription" required="true" requiredposition="right" cols="140" rows="4"/>
					<span id="desPoint"></span>
				</td>
			</tr>
			<tr>
				<th><s:text name="content.contentContext"/>:</th>
				<td id="iframe">
					<textarea id="contentContext" name="content.contentContext" rows="20"><s:property value="content.contentContext"/></textarea>
					<ckeditor:replace  replace="content.contentContext" basePath="${ctx}/common/ckeditor/" />
				</td>
			</tr>
			<tr>
				<th><s:text name="content.contentTpl"/>:</th><!-- <select name="content.contentTpl"></select> -->
				<td>
					<s:if test="content.category.categoryId!=''"><s:select name="content.contentTpl" list="contenttpllist" /></s:if>
					<s:else><s:select name="content.contentTpl" list="toptpllist" /></s:else>
				</td>
			</tr>
			<%-- <tr>
				<th><s:text name="content.isTop"/>:</th>
				<td><s:select name="content.isTop" list="dicIsTop" listKey="dictionaryKey" listValue="dictionaryValue" value="content.isTop" cssClass="selectClass"/></td>
			</tr> --%>
			<s:if test="cflag!=null&&cflag.equals(\"1\")">
				<tr>
					<th>创建时间:</th>
					<td><s:date name="content.createTime" format="yyyy年MM月dd日 HH:mm:ss" /></td>
				</tr>
				<tr>
					<th>修改时间:</th>
					<td><s:date name="content.updateTime" format="yyyy年MM月dd日 HH:mm:ss" /></td>
				</tr>
				<tr>
					<th>发布时间:</th>
					<td><input name="content.publishTime" size="30" class="Wdate" id="qry_startTime_4" readonly="true"  value="<s:date name="content.publishTime" format="yyyy-MM-dd HH:mm:ss"/>"
							onFocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text"/></td>
				</tr>
				<tr>
					<th>发布类型:</th>
					<td>
						发布到：<s:select list="dicPublishType" value="content.publishType" name="content.publishType" cssClass="selectClass" listKey="dictionaryKey" listValue="dictionaryValue"/></td>
				</tr>
				<tr>
					<th>操作日志:</th>
					<td><a href="#this" id="operLog">查看操作日志</a></td>
				</tr>
				<tr>
					<th>审核:</th>
					<td>
					<s:select list="dicAudit" value="content.contentStatus" name="content.contentStatus_t" onchange="publishView()" headerKey="" headerValue="--请选择--" cssClass="selectClass" listKey="dictionaryKey" listValue="dictionaryValue"/>
					<span id="audit_status" style="color:red;display:none;">请选择!</span>
					</td>
				</tr>
				<tr>
					<th><s:text name="content.publishSug"/>:</th>
					<td><s:textarea cols="140" rows="4"  name="content.publishSug" required="true" requiredposition="right" /><span id="keywordssug" style="color:red">请输入审核意见!</span></td>
				</tr>
			</s:if><s:else>
				<tr>
					<th>创建时间:</th>
					<td>
						<s:if test="content.createTime!=null"><s:date name="content.createTime" format="yyyy年MM月dd日 HH:mm:ss" /></s:if>
					</td>
				</tr>
				<tr>
					<th>修改时间:</th>
					<td>
						<s:if test="content.updateTime!=null"><s:date name="content.updateTime" format="yyyy年MM月dd日 HH:mm:ss" /></s:if>
					</td>
				</tr>
				<tr>
					<th>发布时间:</th>
					<td><input name="content.publishTime" size="30"  class="Wdate" id="qry_startTime_1" readonly="true"  value="<s:date name="content.publishTime" format="yyyy-MM-dd HH:mm:ss"/>"
							onFocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text"/></td>
				</tr>
				<tr>
					<th>审核:</th>
					<td> 
						<s:if test="content.contentStatus==1">审核通过</s:if>
						<s:elseif test="content.contentStatus==2">审核未通过</s:elseif>
						<s:else>未审核</s:else>
					</td> 
				</tr>
				<tr>
					<th>审核意见:</th>
					<td> <s:property  value="content.publishSug"  /></td>					 
				</tr>
				<tr>
					<th>发布类型:</th>
					<td>
						发布到：<s:select list="dicPublishType" value="content.publishType" name="content.publishType" cssClass="selectClass" listKey="dictionaryKey" listValue="dictionaryValue"/></td>
				</tr>
			</s:else>
			<tr>
				<th>上传附件:</th>
				<td>
				<input type='text' onclick="up()" Class="txtin" readonly="readonly" id="fileupload"/>
				<input type="button" value="浏览" class="btnlist2" id="brows"/>
				<span id="catContentPhotoAlert" style="color :red">
				<s:property value="content.category.catContentPhotoAlert"/></span>
				<div id="uploaddiv" style="margin-top:-28px;_margin-top: -26px;">
				</form><form name="uploadForm" id="uploadForm"  method="post" enctype="multipart/form-data"  target='hidden_frame'>
					 <input type='file' class='input-def' style="opacity:0;filter:alpha(opacity=0);" size='44' name='upload' value='上传' id='bester' style="height:28px;"  onchange='doSubmitSave(this.value,this)'/>
				</form><form action=""> 
				</div>
				 <iframe name='hidden_frame' id='hidden_frame' style='display:none'></iframe> 				
				</td>
			</tr>
			<tr id="attach">
				<th>附件信息:</th>
				<td><div id="uploads"></div></td>
			</tr>
			<tr>
				<th>&nbsp;</th>
				<td>
				<s:if test="cflag!=null&&cflag.equals(\"1\")">
					<input type="button" value="<s:text name="save"/>" class="btnlist2" onclick="goAudit()"/>
					<s:if test="%{authLicence('3_3_4',content.category.categoryId)&&authLicence('3_3_2',content.category.categoryId)}">
				   		<input type="button" title="审核并发布文章" value="审核发布" disabled="disabled" class="btnlist2" id="savePublish"/>
				  </s:if>
				   <s:elseif test="%{authLicence('4_4_4',topic.topicId)&&authLicence('4_4_2',topic.topicId)}">
				  	<input type="button" title="审核并发布文章" value="审核发布" disabled="disabled" class="btnlist2" id="savePublish"/>
				  </s:elseif>
				</s:if>
				<s:elseif test="%{authLicence('3_3_3',content.category.categoryId)}">
				  <input type="button" value="<s:text name="save"/>" class="btnlist2" id="save"/>
				</s:elseif>
				<s:elseif test="%{authLicence('4_4_3',topic.topicId)}">
				  <input type="button" value="<s:text name="save"/>" class="btnlist2" id="save"/>
				</s:elseif>
				<s:else>
					 <input type="button" value="<s:text name="save"/>" class="btnlist2" id="save"/>
				</s:else>
				<s:if test="content.contentId==null"></s:if><s:else><input type="button" value="<s:text name="preview"/>" class="btnlist2" id="preview"/></s:else>
				<input type="button" value="返回" class="btnlist2" onclick="history.go(-1);"/></td>
			</tr>
		</table>
		</s:form>
	</div>
</div>
</div>
<div id="lightbox" class="lightbox" style=" position: fixed;">
	<div class="lighttit"><p><span><input type="button" value="&nbsp;" id="lightclose" class="lightclose" /><strong>操作日志</strong></span></p></div>
	<div class="lightmain">
		<div class="lightmaintit">操作日志查看</div>
		<div class="ilghtmainbox" style="OVERFLOW-y:auto;OVERFLOW:scroll;overflow-x:auto;">
			<div id="authorSetDiv" >
				<table class="listgridb" cellspacing="1" id="listbox">
					<tbody>
						<tr>						 
							<th>时间</th>
							<th>IP地址</th>
							<th>用户</th>
							<th>操作</th>
		 
						</tr>
						<s:iterator value="operLogList">
							<tr>
							<td><s:property value="operTime"/>&nbsp;</td>
							<td><s:property value="operIp"/>&nbsp;</td>
							<td><s:property value="loginName"/>&nbsp;</td>
							<td><s:property value="operAct"/>&nbsp;</td>
							</tr>
						</s:iterator>
					</tbody>
				</table>
			</div>
		</div>
		<div class="lightbtnbox"><input type="button" value="确认" id="lightsubmit" class="btnlist2" onclick="authorSet()"/></div>
	</div>
</div>
<div id="lightbox_i" class="lightbox" >
	<div class="lighttit"><p><span><input type="button" value="&nbsp;" id="lightclose_i" class="lightclose" /><strong>协同办公文章选择</strong></span></p></div>
	<div class="lightmain">
		<div class="lightmaintit">协同办公文章选择
			<s:select list="#{0:'未导入',1:'已导入' }" name="contentCondition" ></s:select>
			提交时间：<input  name="submitTime" value="<s:date name='submitTime' format='yyyy-MM-dd'/>"  class="Wdate" id="publishTimeId" readonly="true" onFocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" type="text"/>
			<input type="button" value="查询" id="searchContent" class="btnsearch"/>
		</div>
		<div class="ilghtmainbox" style="OVERFLOW-y:auto;OVERFLOW:scroll;overflow-x:auto;">
			<div id="authorSetDiv" >
				<table class="listgridb" cellspacing="1" id="listbox_i">
				<tr><td></td></tr>
				</table>
			</div>
		</div>
		<div class="lightbtnbox">
			<input type="button" value="上一页" id="lastPb" class="btnlist2" />
			<input type="button" value="确认" id="lightsubmit_i" class="btnlist2" />
			<input type="button" value="下一页" id="nextPb" class="btnlist2" />
		</div>
	</div>
</div>
<div style="display: none;" id="nrimportContent_0"></div>
<div style="display: none;" id="nrimportContent_1"></div>
<div style="display: none;" id="nrimportContent_2"></div>
<div style="display: none;" id="nrimportContent_3"></div>
<div style="display: none;" id="nrimportContent_4"></div>
<div style="display: none;" id="nrimportContent_5"></div>
<div style="display: none;" id="nrimportContent_6"></div>
<div style="display: none;" id="nrimportContent_7"></div>
<div style="display: none;" id="nrimportContent_8"></div>
<div style="display: none;" id="nrimportContent_9"></div>

<script type="text/javascript">

	var tomp;
	var isNotSave=true;
	$("#nextPb").click(function(){
		if(parseInt($("input[name=pb]").val())*10>=parseInt($("input[name=pbMax]").val())){
			alert("已经是最后一页！");
			return false;
		}
		var contentCondt = $("select[name=contentCondition]").val();
		var subTime = $("input[name=submitTime]").val();
		$("#listbox_i").html("");
		$.ajax({	
			url:"${ctx}/content/content-import.action?time="+new Date().getTime(),
			data:{"pbBasic.pageNo":parseInt($("input[name=pb]").val())+1, "contentCondition":contentCondt, "submitTime":subTime},
			dataType:"text",
			success:function(data){
				var str = "<tbody>";
				var json = eval('('+data+')');
				
				$("input[name=pb]").val(json[0].pageNo);
				$("input[name=pbMax]").val(json[0].pageMax);
				str+="<tr>";
				str+="<th class='w40'>选择</th>";
				str+="<th>标题</th>";
				str+="<th>提交时间</th>";
				str+="<th>提交协会</th>";
				str+="<th>文章导入状态</th>";
				str+="</tr>";
				for(var i = 0 ; i<json.length ; i++){
					$("#nrimportContent_"+i).html(json[i].nr);
					str+="<tr>";
					str+="<td><input type='radio' name='importContent' value='importContent_"+i+"'/><div style='display:none' id='importContent_"+i+"'>"+json[i].basicId+"@"+json[i].title+"@"+json[i].source+"@"+json[i].keyword+"</div></td>";
					str+="<td class='left'>"+json[i].title+"</td>";
					str+="<td>"+json[i].editTime+"</td>";
					str+="<td>"+json[i].source+"</td>";
					if(json[i].isImport=="true") {
						str+="<td>已导入</td>";
					}else {
						str+="<td>未导入</td>";
					}
					str+="</tr>";
				}
				str+="</tbody>";
				$("#listbox_i").append(str);
			}
		});
		$$.shade("#import","#lightclose_i,#lightsubmit_i","#lightbox_i","700");
	});
	$("#lastPb").click(function(){
		if($("input[name=pb]").val()==1){
			alert("已经是第一页！");
			return false;
		}
		var contentCondt = $("select[name=contentCondition]").val();
		var subTime = $("input[name=submitTime]").val();
		$("#listbox_i").html("");
		$.ajax({	
			url:"${ctx}/content/content-import.action?time="+new Date().getTime(),
			data:{"pbBasic.pageNo":$("input[name=pb]").val()-1, "contentCondition":contentCondt, "submitTime":subTime},
			dataType:"text",
			success:function(data){
				var str = "<tbody>";
				var json = eval('('+data+')');
				$("input[name=pb]").val(json[0].pageNo);
				$("input[name=pbMax]").val(json[0].pageMax);
				str+="<tr>";
				str+="<th class='w40'>选择</th>";
				str+="<th>标题</th>";
				str+="<th>提交时间</th>";
				str+="<th>提交协会</th>";
				str+="<th>文章导入状态</th>";
				str+="</tr>";
				for(var i = 0 ; i<json.length ; i++){
					$("#nrimportContent_"+i).html(json[i].nr);
					str+="<tr>";
					str+="<td><input type='radio' name='importContent' value='importContent_"+i+"'/><div style='display:none' id='importContent_"+i+"'>"+json[i].basicId+"@"+json[i].title+"@"+json[i].source+"@"+json[i].keyword+"</div></td>";
					str+="<td class='left'>"+json[i].title+"</td>";
					str+="<td>"+json[i].editTime+"</td>";
					str+="<td>"+json[i].source+"</td>";
					if(json[i].isImport=="true") {
						str+="<td>已导入</td>";
					}else {
						str+="<td>未导入</td>";
					}
					str+="</tr>";
				}
				str+="</tbody>";
				$("#listbox_i").append(str);
			}
		});
		$$.shade("#import","#lightclose_i,#lightsubmit_i","#lightbox_i","700");
	});
	$("#import").click(function(){
		$("#listbox_i").html("");
		$("input[name=submitTime]").val("");
		var contentCondt = $("select[name=contentCondition]").val();
		$.ajax({	
			url:"${ctx}/content/content-import.action?",
			data:{"contentCondition":contentCondt},
			success:function(data){
				var str="<tbody>";
				var json = eval('('+data+')');
				$("input[name=pb]").val(json[0].pageNo);
				$("input[name=pbMax]").val(json[0].pageMax);
				str+="<tr>";
				str+="<th class='w40'>选择</th>";
				str+="<th>标题</th>";
				str+="<th>提交时间</th>";
				str+="<th>提交协会</th>";
				str+="<th>文章导入状态</th>";
				str+="</tr>";
				for(var i = 0 ; i<json.length ; i++){
					$("#nrimportContent_"+i).html(json[i].nr);
					str+="<tr>";
					str+="<td><input type='radio' name='importContent' value='importContent_"+i+"'/><div style='display:none' id='importContent_"+i+"'>"+json[i].basicId+"@"+json[i].title+"@"+json[i].source+"@"+json[i].keyword+"</div></td>";
					str+="<td class='left'>"+json[i].title+"</td>";
					str+="<td>"+json[i].editTime+"</td>";
					str+="<td>"+json[i].source+"</td>";
					if(json[i].isImport=="true") {
						str+="<td>已导入</td>";
					}else {
						str+="<td>未导入</td>";
					}
					str+="</tr>";
				}
				str+="</tbody>";
				$("#listbox_i").append(str);
			}
		});
		$$.shade("#import","#lightclose_i,#lightsubmit_i","#lightbox_i","700");
	});
	$("#searchContent").click(function(){
		var contentCondt = $("select[name=contentCondition]").val();
		var subTime = $("input[name=submitTime]").val();
		$("#listbox_i").html("");
		$.ajax({
			url:"${ctx}/content/content-import.action?time="+new Date().getTime(),
			data:{"contentCondition":contentCondt, "submitTime":subTime},
			//dataType:"text",
			success:function(data){
				var str="<tbody>";
				var json = eval('('+data+')');
				$("input[name=pb]").val(json[0].pageNo);
				$("input[name=pbMax]").val(json[0].pageMax);
				str+="<tr>";
				str+="<th class='w40'>选择</th>";
				str+="<th>标题</th>";
				str+="<th>提交时间</th>";
				str+="<th>提交协会</th>";
				str+="<th>文章导入状态</th>";
				str+="</tr>";
				for(var i = 0 ; i<json.length ; i++){
					$("#nrimportContent_"+i).html(json[i].nr);
					str+="<tr>";
					str+="<td><input type='radio' name='importContent' value='importContent_"+i+"'/><div style='display:none' id='importContent_"+i+"'>"+json[i].basicId+"@"+json[i].title+"@"+json[i].source+"@"+json[i].keyword+"</div></td>";
					str+="<td class='left'>"+json[i].title+"</td>";
					str+="<td>"+json[i].editTime+"</td>";
					str+="<td>"+json[i].source+"</td>";
					if(json[i].isImport=="true") {
						str+="<td>已导入</td>";
					}else {
						str+="<td>未导入</td>";
					}
					str+="</tr>";
				}
				str+="</tbody>";
				$("#listbox_i").append(str);
			}
		});
		$$.shade("#import","#lightclose_i,#lightsubmit_i","#lightbox_i","700");
	});
	$("#lightsubmit_i").click(function(){
		var flag = false;
		$("input[name=importContent]").each(function(){
			if($(this).attr("checked")==true){
				flag = true;
			}
		});
		if(flag){
			var index = $("input[name=importContent]:checked").val();
			var rs = $("#"+index).html().split("@");
			var nr = $("#nr"+index).html();
			$("input[name=listId]").val(rs[0]);
			$("#contentTitle").val(rs[1]);
			$("#contentSource").val(rs[2]);
			$("#keywords").val(rs[3]);
			$("iframe").contents().find(".cke_show_borders").html("");
			$("iframe").contents().find(".cke_show_borders").append(nr);
		}
	});
	$("#operLog").click(function(){
		$$.shade("#operLog","#lightclose,#lightsubmit","#lightbox","600");
	});
	$("#brows").click(function(){
		//$("#uploadForm").show();
		$("#bester").click();
		//$("#uploadForm").hide();
	});
	function up(){
		//$("#uploadForm").show();
		$("#bester").click();
		//$("#uploadForm").hide();
	}
	$("#preview").click(function(){
		var contentId = $("input[name=content.contentId]").val();
		window.open("${ctx}/generate/preview.action?targets="+contentId+"&type=content");
	});
	window.onbeforeunload=function (){
	};
	window.onunload = function (){
		//文章解锁
		<s:if test="content.contentId!=null">
			if(isNotSave){
				$.post("content-ajaxunlock.action?content.contentId=<s:property value="content.contentId"/>&status=<s:property value="status"/>");
			}
		</s:if>
		//进行数据清除		
		if($("input[name=content.contentId]").val()!=""&&$("#contentTitle").val()==""){
			var contentId = $("input[name=content.contentId]").val();
			$.ajax({	
				url:"${ctx}/content/content-delete.action?time="+new Date().getTime(),
				data:{"key":contentId},
				dataType:"text",
				success:function(data){
					
				},
				error:function(data){
					alert("删除失败");
				}
			});
		}
		tomp[0].removeChild(tomp[1]);
		tomp[0].removeChild(tomp[2]);
	};
	
	//输入1秒后检测文章标题
	 var timer = false;
    function checkTitle() {
    if (timer) {
          clearTimeout(timer);
          timer = false;
   }
	 timer = setTimeout(function () {
		   checkUniName();
	 }, 300);
	}
    
	//进行文章标题唯一检测
	function checkUniName(){
		var contentTitle=$("#contentTitle").val();
		contentTitle=$.trim(contentTitle);
		var obj = {"content.contentTitle":contentTitle};
		if(contentTitle != null && contentTitle != ""){
			$.post("${ctx}/content/content-checknameunique.action",obj,function(data){
				if(data != "ok"){
					$("#contentTitleno").css("color","red");
					$("#contentTitleno").html("已存在一篇同样标题的文章");
				}else{
				}
			});
		  }
	}
	
	 $("#contentTitle").blur(function(){
			var maxLen=100;
			var contentTitle=$("#contentTitle").val();
			
			 str = jQuery.trim(contentTitle);
			 document.getElementById("contentTitle").value=str;
			 
			contentTitle=$.trim(contentTitle);
			if((contentTitle==""||contentTitle.length==0)){
				$("#contentTitleno").html("文章标题不能为空");
				$("#contentTitleno").css("color","red");
			}
			if(contentTitle!=""){
				$("#contentTitleno").html("");
			}
			if ((contentTitle.length )> maxLen) {
				var ss=$("#contentTitle").val( $("#contentTitle").val().substr(0, maxLen) );
				$("#contentTitleno").html("文章标题过长");
				$("#contentTitleno").css("color","red");
			}
		});
	 $("#contentSource").blur(function(){
				var maxLen=100;
				var contentSource=$("#contentSource").val();
				
				 str = jQuery.trim(contentSource);
				 document.getElementById("contentSource").value=str;
				 
				contentSource=$.trim(contentSource);
				if((contentSource==""||contentSource.length==0)){
					$("#contentSourceno").html("文章来源不能为空");
					$("#contentSourceno").css("color","red");
				}
				if(contentSource!=""){
					$("#contentSourceno").html("");
				}
				if ((contentSource.length )> maxLen) {
					var ss=$("#contentSource").val( $("#contentSource").val().substr(0, maxLen) );
					$("#contentSourceno").html("字符过长");
					$("#contentSourceno").css("color","red");
				}
		});
     $("#keywords").blur(function(){
				var maxLen=100;
				var keywords=$("#keywords").val();
				
				 str = jQuery.trim(keywords);
				 document.getElementById("keywords").value=str;
				 
				keywords=$.trim(keywords);
				if ((keywords.length )> maxLen) {
					var ss=$("#keywords").val( $("#keywords").val().substr(0, maxLen) );
					$("#keywordsno").html("字符过长");
					$("#keywordsno").css("color","red");
				}
		});
      $("#contentDescription").blur(function(){
				var maxLen=250;
				var contentDescription=$("#contentDescription").val();
				contentDescription=$.trim(contentDescription);
				if($("#contentDescription").val()!=""){
					$("#contentDescriptionno").html("");
				}
				if (($("#contentDescription").val().length )> maxLen) {
					var ss=$("#contentDescription").val( $("#contentDescription").val().substr(0, maxLen) );
					$("#contentDescriptionno").html("字符过长");
					$("#contentDescriptionno").css("color","red");
				}
		}); 
		
	
	$('#save').click(function(){
		var contentTitle = $("#contentTitle").val();
		var contentDescription = $("#contentDescription").val();
		var contentSource = $("#contentSource").val();
		if(contentTitle==""){
			alert('请输入文章标题');
			return false;
		}
		if(contentSource==""){
			alert('请输入文章来源');
			return false;
		}
		 if(contentDescription==""){
			alert('请输入简述内容');
			return false;
		}  
		if($("input[name=isTop_f]").attr("checked")==""){
			$("input[name=content.isTop]").val(false);
		}else{
			$("input[name=content.isTop]").val(true);
		}
		var showType = $("select[name=showType_1]").val();
		$("input[name=showType_o]").each(function(){
			if($(this).attr("checked")==""){
				showType+="0";
			}else{
				showType+="1";
			}
		});
		showType+="0";
		$("input[name=content.showType]").val(showType);
		chkform();
	});
	
	
 	var ajaxAction = '${ctx}';
	function chkform(){
		var contentId = $('#itemId').val();
		var attachId = document.getElementsByName('attachId');
		var attachMemo = document.getElementsByName('contentAttach.attachMemo');
		var ttId = '';
		var ttMemo = '';
		for(var i = 0 ; i < attachId.length;i++){
			ttId+=attachId[i].value+'@';
		}
		for(var i = 0 ; i < attachMemo.length;i++){
			if(attachMemo[i].value==''){
				ttMemo+=' @';
			}else{
				ttMemo+=attachMemo[i].value+'@';
			}
		}
		ttMemo = ttMemo.substring(2,ttMemo.length);
		$('input[name=content.contentId]').val(contentId);
		$('input[name=contentAttach.attachId]').val(ttId);
		$('#memo').val(ttMemo);
		$("#uploaddiv").remove();
		isNotSave=false;		
		$("#save-form").submit();
		
	}
	
	$("#savePublish").click(function(){
		var contentTitle = $("#contentTitle").val();
		var contentDescription = $("#contentDescription").val();
		var contentSource = $("#contentSource").val();
		if(contentTitle==""){
			alert('请输入文章标题');
			return false;
		}
		if(contentSource==""){
			alert('请输入文章来源');
			return false;
		}
		 if(contentDescription==""){
			alert('请输入简述内容');
			return false;
		}  
		if($("input[name=isTop_f]").attr("checked")==""){
			$("input[name=content.isTop]").val(false);
		}else{
			$("input[name=content.isTop]").val(true);
		}
		var showType = $("select[name=showType_1]").val();
		$("input[name=showType_o]").each(function(){
			if($(this).attr("checked")==""){
				showType+="0";
			}else{
				showType+="1";
			}
		});
		showType+="0";
		$("input[name=content.showType]").val(showType);
		var contentId = $('#itemId').val();
		var attachId = document.getElementsByName('attachId');
		var attachMemo = document.getElementsByName('contentAttach.attachMemo');
		var ttId = '';
		var ttMemo = '';
		for(var i = 0 ; i < attachId.length;i++){
			ttId+=attachId[i].value+'@';
		}
		for(var i = 0 ; i < attachMemo.length;i++){
			if(attachMemo[i].value==''){
				ttMemo+=' @';
			}else{
				ttMemo+=attachMemo[i].value+'@';
			}
		}
		ttMemo = ttMemo.substring(2,ttMemo.length);
		$('input[name=content.contentId]').val(contentId);
		$('input[name=contentAttach.attachId]').val(ttId);
		$('#memo').val(ttMemo);
		$("#uploaddiv").remove();
		$("input[name='content.andPub']").remove();
		if(confirm("要同步更新栏目列表及首页吗?\n这样会使发布速度非常慢!\n点击[确定]发布栏目及首页!\n点击[取消]只发布文章!")){
			$("<input type='hidden' name='content.andPub' value='1'/>").appendTo("#save-form");
			tomp=$$.now_loading("正在发布栏目列表及首页...");
			isNotSave=false;
			$("#save-form").submit();
		}
		else{
			$("<input type='hidden' name='content.andPub' value='2'/>").appendTo("#save-form");
			tomp=$$.now_loading("正在发布文章...");
			isNotSave=false;
			$("#save-form").submit();
		}
	});
	
	
	function goAudit(){
		if($('select[name=content.contentStatus_t] option:selected').val()==''){
			$("#audit_status").show();
			return false;
		}
		else if($('select[name=content.contentStatus_t] option:selected').val()==2){
			$("#audit_status").hide();
			if($("textarea[name=content.publishSug]").val()==""){
				$("#keywordssug").show();
				return false;
			}else{
				$("#keywordssug").hide();
			}
		}
		var cflag = $('select[name=content.contentStatus_t]').val();
		$("input[name=content.contentStatus]").val($("select[name=content.contentStatus_t] option:selected").val());
		$('#cflag').val(cflag);
		isNotSave=false;	
		$('#save-form').submit();
	}
	$(document).ready(function() {
		/* if(window.FileReader){
			alert(1);
		}else{
			alert(2);
		} */
		<s:if test="content.simpleTitle1==null">
			$("#simpleT_1").hide();
		</s:if>
		<s:if test="content.simpleTitle2==null">
			$("#simpleT_2").hide();
		</s:if>
		<s:if test="content.simpleTitle3==null">
			$("#simpleT_3").hide();
		</s:if>
		//$("#uploadForm").hide();
		$("#attach").hide();
		$("#keywordssug").hide();
		if($('#itemId').val()==null){
		}else{
			$('input[name=content.contentId]').val($('#itemId').val());
		}
		listFile($('input[name=content.contentId]').val(),"content");
		if($("input[name=content.isTop]").val()=="false"||$("input[name=content.isTop]").val()==""){
			$("input[name=isTop_f]").attr("checked","");
		}else{
			$("input[name=isTop_f]").attr("checked","checked");
		}
		var showType = $("input[name=content.showType]").val();
		$("select[name=showType_1]").val(showType.charAt(0));
		$("input[name=showType_o]").each(function(i){
			 
			if(showType.charAt(i+2)=="1"){
				$(this).attr("checked","checked");
			}
		});
		$("#keywordssug").hide();

		/* var tpl = "<s:property value="content.category.catContentTplSet"/>";
		if(tpl==""){
			$("select[name=content.contentTpl] option").remove();
			var str = "<option value=''>默认模板</option>";
			$("select[name=content.contentTpl]").append(str);
		}else{
			var obj = tpl.split(",");
			var str = "<option value=''>默认模板</option>";
			for(var i = 0 ; i < obj.length ; i++){
				str+="<option value="+obj[i]+">"+obj[i]+"</option>";
			}
			$("select[name=content.contentTpl]").append(str);
		} */
		
		<s:if test="cflag!=null&&cflag.equals(\"1\")">
		publishView();
		</s:if>
		
	});
	function initBar(){
		 $("#pb2").progressBar({ barImage: '../images/progressbg_yellow.gif'} );
		 $('#pb2').progressBar(1);
	}
	function percentBar(x){
		$('#pb2').progressBar(x);
	}
	function addSimpleTitle(){
		if($("#simpleT_1").attr("name")!="show"){
			$("#simpleT_1").attr("name","show");
			$("#simpleT_1").show();
		}else if($("#simpleT_2").attr("name")!="show"){
			$("#simpleT_2").attr("name","show");
			$("#simpleT_2").show();
		}else if($("#simpleT_3").attr("name")!="show"){
			$("#simpleT_3").attr("name","show");
			$("#simpleT_3").show();
		}else{
			alert("只可增加3个幅标题！");
		}
	}
	function removeSimpleTitle(obj){
		$("#"+obj).hide();
		$("#"+obj).attr("name","hide");
		$("#"+obj+" input").val('');
	}
	function inFile(obj,name){
		var ext = obj.substring(obj.lastIndexOf(".")+1,obj.length);
		var str = "";
		if(ext=="jpg"||ext=="png"||ext=="gif"||ext=="jpeg"||ext=="bmp"){
			str+="<img src='";
			str+=obj;
			str+="' />";
		}else{
			str+="<a href='";
			str+=obj;
			str+="' target='_blank'>";
			str+=name;
			str+="</a>";
		}
		CKEDITOR.instances.contentContext.insertHtml(str);
	}
	
	//文章简述判空
	function checkDes(str){
		var decCont =  $("#contentDescription").val();
		if(decCont == null  || decCont == ""){
			$("#desPoint").css("color","red");
			$("#desPoint").html("文章简述不能为空");
		}else{
			$("#desPoint").html("");
		}
		
		 str = jQuery.trim(str.value);
		 document.getElementById("contentDescription").value=str;
	}
	function publishView(){
		var publishBtn = $("#savePublish");
		var s = $('select[name=content.contentStatus_t] option:selected').val();
		if(publishBtn.val()!='undefined'){
			if(s==1){
				publishBtn.attr("disabled",false);
				$("#audit_status").hide();
			}	
			else if(s==2){
				publishBtn.attr("disabled",true);
				$("#audit_status").hide();
			}
			else{
				publishBtn.attr("disabled",true);
				$("#audit_status").show();
			}
		}
			
	}
	
	function contentAuthor(str){
         str = jQuery.trim(str.value);
         document.getElementById("content.contentAuthor").value=str;
	}
    function simpleTitle1(str){
		 str = jQuery.trim(str.value);
		 document.getElementById("content.simpleTitle1").value=str;
    }
    function simpleTitle2(str){
		 str = jQuery.trim(str.value);
		 document.getElementById("content.simpleTitle2").value=str;
    }
    function simpleTitle3(str){
		 str = jQuery.trim(str.value);
		 document.getElementById("content.simpleTitle3").value=str;
    }
    $(function(){
		if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
			$('#main_box').width($('#main_box').width()-25);
		}
	});	

</script>
</body>
</html>
